---
--- Created by root.
--- DateTime: 17-11-20 下午1:53
---

--local db = require "frame.model"

local article = require "app.model.article" --文章模型
cookie = require "frame.cookie"
local request = require "frame.request"

local _OBJ = {}
function _OBJ.test()
    local content = view:display({"header","index.content"}, {test={id=1},title="这是title"} )
    return content,"html"
end

--获取文章列表
function _OBJ.index()
    local args = request:post()
    local page = args["page"] or 1
    local size = args["size"] or 5
    local search_key = args["search"] or ""
    local data = article:articleList(search_key, page, size)
    return  data
end

function _OBJ.post()
    local args = request:post()
    if not args["content"] or not args["image"] or not args["intro"] or not args["title"] or not args["class"] then
        return "内容不能为空"
    else
        local res = article:add(args["content"], args["image"], args["intro"], args["title"], args["class"])
        return res
    end
end

function _OBJ.detail()
    local args = request:get()

    local data = article:detail(args[3])
    return data
end
return _OBJ